package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.ChargeRefundEntity;
import com.jinmdz.fmis.mapper.mapper.provider.ChargeRefundProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 费用退费表Mapper
 *
 * @author generator
 * @date 2020-05-12 14:24
 */
public interface ChargeRefundMapper {

    /**
     * 增加ChargeRefund
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-05-12 14:24
     */
    @InsertProvider(type = ChargeRefundProvider.class, method = "insertChargeRefund")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertChargeRefund(@Param("entity") ChargeRefundEntity entity);

    /**
     * 删除ChargeRefund
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-05-12 14:24
     */
    @Update(" update charge_refund set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForChargeRefund(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改ChargeRefund
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-05-12 14:24
     */
    @UpdateProvider(type = ChargeRefundProvider.class, method = "updateChargeRefund")
    void updateChargeRefund(@Param("entity") ChargeRefundEntity entity);

    /**
     * 查询ChargeRefund实体
     *
     * @param id 主键
     * @return ChargeRefundEntity
     * @author generator
     * @date 2020-05-12 14:24
     */
    @Select(" select id,deleted,business_code,charge_item_id,refund_charge,refund_minus_id,refund_new_id,refund_time,remark,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from charge_refund where id = #{id} and deleted = 0 limit 1 ")
    ChargeRefundEntity getChargeRefundById(@Param("id") Integer id);

    /**
     * 查询ChargeRefund列表
     *
     * @param entity 数据实体
     * @return ChargeRefundEntity
     * @author generator
     * @date 2020-05-12 14:24
     */
    @SelectProvider(type = ChargeRefundProvider.class, method = "listChargeRefund")
    ArrayList<ChargeRefundEntity> listChargeRefund(@Param("entity") ChargeRefundEntity entity);
}